const Koa = require('koa')
const bodyParser = require('koa-bodyparser') //解决koa无法解析post传过来的参数
const cors = require('koa2-cors')  //解决跨域的问题
const userRouter = require('./routes/user.js')
const productRouter=require('./routes/product.js')
const orderRouter=require('./routes/order.js')
const eventRouter=require('./routes/event.js')
const addressRouter=require('./routes/address.js')

// const { koaBody } = require('koa-body');

const app = new Koa()
app.use(cors());
app.use(bodyParser());
// app.use(koaBody({
//   multipart: true,
//   formidable: {
//     maxFileSize: 200 * 1024 * 1024, // 设置允许上传文件的最大大小为 20MB
//   },
// }));

// 注册路由
app.use(userRouter.routes(),userRouter.allowedMethods())
app.use(productRouter.routes(),productRouter.allowedMethods())
app.use(orderRouter.routes(),orderRouter.allowedMethods())
app.use(eventRouter.routes(),eventRouter.allowedMethods())
app.use(addressRouter.routes(),addressRouter.allowedMethods())


app.listen(3000, (err) => {
  console.log('项目启动在3000端口');
})